package net.sk.china.city.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import net.sk.china.city.controller.base.BaseController;
import net.sk.china.city.domain.dto.AjaxResult;
import net.sk.china.city.domain.ArOrder;
import net.sk.china.city.service.IArOrderService;
import net.sk.china.city.domain.dto.TableDataInfo;

/**
 * 订单管理Controller
 *
 * @author ruoyi
 * @date 2024-06-06
 */
@RestController
@RequestMapping("/yigoHome/order")
@Api(tags = "订单管理")
public class ArOrderController extends BaseController
{
    @Autowired
    private IArOrderService arOrderService;

    /**
     * 查询订单管理列表
     */
    @PreAuthorize("hasAnyAuthority('yigoHome:order:list')")
    @GetMapping("/list")
    @ApiOperation("查询订单管理列表")
    public TableDataInfo list(ArOrder arOrder)
    {
        startPage();
        List<ArOrder> list = arOrderService.selectArOrderList(arOrder);
        return getDataTable(list);
    }

    /**
     * 导出订单管理列表
     */
    @PreAuthorize("hasAnyAuthority('yigoHome:order:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArOrder arOrder)
    {
        List<ArOrder> list = arOrderService.selectArOrderList(arOrder);
//        ExcelUtil<ArOrder> util = new ExcelUtil<ArOrder>(ArOrder.class);
//        util.exportExcel(response, list, "订单管理数据");
    }

    /**
     * 获取订单管理详细信息
     */
    @ApiOperation("获取订单管理详细信息")
    @PreAuthorize("hasAnyAuthority('yigoHome:order:query')")
    @GetMapping(value = "/{pkId}")
    public AjaxResult getInfo(@PathVariable("pkId") Long pkId)
    {
        return success(arOrderService.selectArOrderByPkId(pkId));
    }

    /**
     * 新增订单管理
     */
    @PreAuthorize("hasAnyAuthority('yigoHome:order:add')")
    @PostMapping
    public AjaxResult add(@RequestBody ArOrder arOrder)
    {
        return toAjax(arOrderService.insertArOrder(arOrder));
    }

    /**
     * 修改订单管理
     */
    @ApiOperation("修改订单管理")
    @PreAuthorize("hasAnyAuthority('yigoHome:order:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody ArOrder arOrder)
    {
        return toAjax(arOrderService.updateArOrder(arOrder));
    }

    /**
     * 删除订单管理
     */
    @ApiOperation("删除订单管理")
    @PreAuthorize("hasAnyAuthority('yigoHome:order:remove')")
    @DeleteMapping("/{pkIds}")
    public AjaxResult remove(@PathVariable Long[] pkIds)
    {
        return toAjax(arOrderService.deleteArOrderByPkIds(pkIds));
    }
}
